﻿using AMing.Mvc4.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AMing.Mvc4.Controllers
{
    public class BaseController : Controller
    {
        private HostnameHelperEX _hostName = null;
        /// <summary>
        /// 主机名跳转
        /// </summary>
        public HostnameHelperEX HostName
        {
            get
            {
                if (_hostName == null)
                {
                    _hostName = new HostnameHelperEX(this.HostNameViewData, this.Request);
                }
                return _hostName;
            }
            set { _hostName = value; }
        }


        private HostNameView _hostNameViewData = null;
        /// <summary>
        /// 根据主机名选择指定视图页
        /// </summary>
        public HostNameView HostNameViewData
        {
            get
            {
                if (_hostNameViewData == null)
                {
                    _hostNameViewData = new HostNameView(this.View);
                }
                return _hostNameViewData;
            }
            set { _hostNameViewData = value; }
        }

        protected HostNameViewResult HostNameView(string viewpath)
        {
            return new HostNameViewResult() { ViewPath = viewpath };
        }

        protected HostNameActionResult HostNameParams(Web.HostNameEnum hostNameEnum, ActionResult actionResult)
        {
            return new HostNameActionResult(hostNameEnum, actionResult);
        }
        protected HostNameActionResult HostNameParams(Web.HostNameEnum hostNameEnum, Func<ActionResult> actionResult)
        {
            return new HostNameActionResult(hostNameEnum, actionResult);
        }

        protected void SetNavIndex(int index)
        {
            ViewBag.NavIndex = index.ToString();
        }
    }
}
